package com.ghost.alibabaghost.service.sys;

import com.ghost.alibabaghost.api.service.sys.SysRoleMenuService;
import com.ghost.alibabaghost.api.model.sys.SysRoleMenuModel;
import com.ghost.alibabaghost.dao.dataobject.sys.SysRoleMenuDO;
import com.ghost.alibabaghost.dao.mapper.sys.SysRoleMenuMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yaolisheng
 * @version 1.0
 * @date 2022/1/15 09:32
 */
@Service("sysRoleMenuService")
public class SysRoleMenuServiceImpl implements SysRoleMenuService {

    @Autowired
    private SysRoleMenuMapper sysRoleMenuMapper;

    @Override
    public SysRoleMenuModel queryRoleMenuByRoleId(Integer roleId) {
        SysRoleMenuDO sysRoleMenuDO = sysRoleMenuMapper.queryRoleMenuByRoleId(roleId);
        SysRoleMenuModel sysRoleMenuModel = new SysRoleMenuModel();
        BeanUtils.copyProperties(sysRoleMenuDO,sysRoleMenuModel);
        return sysRoleMenuModel;
    }

    @Override
    public Integer insertRoleMenu(SysRoleMenuModel sysRoleMenuModel) {
        SysRoleMenuDO sysRoleMenuDO = new SysRoleMenuDO();
        BeanUtils.copyProperties(sysRoleMenuModel,sysRoleMenuDO);
        return sysRoleMenuMapper.insertRoleMenu(sysRoleMenuDO);
    }

    @Override
    public Integer updateRoleMenu(SysRoleMenuModel sysRoleMenuModel) {
        SysRoleMenuDO sysRoleMenuDO = new SysRoleMenuDO();
        BeanUtils.copyProperties(sysRoleMenuModel,sysRoleMenuDO);
        return sysRoleMenuMapper.updateRoleMenu(sysRoleMenuDO);
    }
}
